﻿@model GPS.ENTITYS.CrudModelDKH_LOP_DD

@{
    ViewBag.Title = "Sửa điểm danh học viên";
}

@using (Html.BeginForm("Edit", "GPS_DiemDanh", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)
    <h3 class="text-center fdb-title-search-form">Sửa thông tin điểm danh</h3>
    <div id="tabs">
        <div id="tabs-1">
            @Html.Hidden("IsEdit", 0)
            @Html.HiddenFor(model => model.KH_LOP_DD_MA)
            <fieldset class="fs_body">
                <legend class="head_title">Thông tin chi tiết điểm danh</legend>

                <div class="row margin-top-05">
                    <div class="col-md-2 control-label text-left">
                        Đơn vị đào tạo
                    </div>
                    <div class="col-md-4">
                        @Html.DropDownListFor(model => model.KH_LOP_DD_DVGTVT_MA, (SelectList)ViewBag.DVGTVT_MAs, string.Empty, new { @class = "form-control", @id = "ddlDVGTVT_MA",@readonly="readonly" })
                        @Html.ValidationMessageFor(model => model.KH_LOP_DD_DVGTVT_MA)
                    </div>

                    <div class="col-md-2 control-label text-left">
                        Mã khóa học
                    </div>
                    <div class="col-md-4">
                        @Html.DropDownListFor(model => model.KH_LOP_DD_KH_MA, (SelectList)ViewBag.KH_MAs, string.Empty, new { @class = "form-control", @id = "ddlKH_MA", @readonly = "readonly" })
                        @Html.ValidationMessageFor(model => model.KH_LOP_DD_KH_MA)
                    </div>
                </div>

                <div class="row margin-top-05">
                    <div class="col-md-2 control-label text-left">
                        Mã lớp học
                    </div>
                    <div class="col-md-4">
                        @Html.DropDownListFor(model => model.KH_LOP_DD_KH_LOP_MA, (SelectList)ViewBag.KH_LOP_MAs, string.Empty, new { @class = "form-control", @id = "ddlLOP_MA", @readonly = "readonly" })
                        @Html.ValidationMessageFor(model => model.KH_LOP_DD_KH_LOP_MA)
                    </div>
                    <div class="col-md-2 control-label">
                        Giai đoạn
                    </div>
                    <div class="col-md-4">

                        @Html.DropDownListFor(model => model.KH_LOP_DD_GIAIDOAN_MA, new List<SelectListItem>
                                {                   new SelectListItem() {Text = "", Value=""},
                                                    new SelectListItem() {Text = "Lý thuyết", Value="LT"},
                                                    new SelectListItem() {Text = "Thực hành", Value="TH"},
                                                    new SelectListItem() {Text = "Thực hành đường", Value="TD"}
                                }, new { @class = "form-control" })

                    </div>

                </div>

                <div class="row margin-top-05">
                    <div class="col-md-2 control-label">
                        Hạng đào tạo
                    </div>
                    <div class="col-md-4">
                        @Html.TextBox("txtHANGDT", (string)ViewBag.HANGHT, new { @class = "form-control", @id = "txtHANGDT", @readonly = "readonly" })
                    </div>

                    <div class="col-md-2 control-label">
                        Ngày điểm danh
                    </div>
                    <div class="col-md-4">
                        @Html.TextBoxFor(model => model.KH_LOP_DD_NGAYDD, "{0:dd/MM/yyyy}", new { @class = "form-control" })
                    </div>
                </div>

                <div class="row margin-top-05">
                    <div class="col-md-2 control-label text-left">
                        Mã học viên
                    </div>
                    <div class="col-md-10">
                        @Html.TextBoxFor(model => model.KH_LOP_DD_HV_MA,  new { @class = "form-control",@readonly="readonly" })
                    </div>
                    <div class="col-md-2 control-label text-left">
                        Tên học viên
                    </div>
                    <div class="col-md-10">
                        @Html.TextBox("txtHV_TEN", (string)ViewBag.HV_TEN, new { @class = "form-control", @readonly = "readonly" })
                    </div>

                </div>

                <div class="row margin-top-05">
                    <div class="col-md-2 control-label">
                        Đi học?
                    </div>
                    <div class="col-md-4">
                        @Html.DropDownListFor(model => model.KH_LOP_DD_COHOC, new List<SelectListItem>
                                {                   new SelectListItem() {Text = "Đi học", Value="1"},
                                                    new SelectListItem() {Text = "Vắng", Value="0"}
                                }, new { @class = "form-control" })
                    </div>
                </div>


            </fieldset>
        </div>
    </div>
    <br />
    <div class="row">
        <div class="col-md-12">
            <button type="submit" class="btn btn-danger btn-sm">
                <span class="glyphicon glyphicon-floppy-disk"></span> Cập nhật
            </button>
            &nbsp;&nbsp;
            @Html.ActionLink("Quay lại", "Index", null, new { @class = "btn btn-primary btn-sm" })
        </div>
    </div>
}
<link href="~/Content/bootstrap-datetimepicker.min.css" rel="stylesheet" />
<script src="~/Scripts/bootstrap-datetimepicker.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="~/Scripts/locales/bootstrap-datetimepicker.fr.js" charset="UTF-8"></script>

<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>

<script src="~/Scripts/datepicker.js"></script>
<script src="~/Scripts/jquery-ui-1.11.4.js"></script>
<script src="~/Scripts/jquery.maskedinput.js"></script>
<script src="~/Scripts/jquery.maskMoney.js"></script>
<script src="~/Scripts/jquery.number.js"></script>
<script src="~/Scripts/jquery.masknumber.js"></script>
<script src="~/Scripts/moment.js"></script>


<script type="text/javascript">
    // Voi jQuery 1.9 > thi chi validate gia tri trong active tab
    // Muon validate nhung gia tri trong cac tab khac nua thi dung jquery.validate 1.8.1 or 1.7
    // mask edit cho truong ngay thang (su dung jquery.maskedinput)
    function ToJavaScriptDate(value) {
        if (value != null) {
            var pattern = /Date\(([^)]+)\)/;
            var results = pattern.exec(value);
            var dt = new Date(parseFloat(results[1]));
            return dt.getDate() + "/" + (dt.getMonth() + 1) + "/" + dt.getFullYear();
        }
        return null;
    }
</script>
<script type="text/javascript">
    //$("#KH_LOP_LH_TUNGAY").datepicker({
    //    changeMonth: true,
    //    changeYear: true,

    //    dateFormat: 'dd/mm/yy'
    //});

    $("#KH_LOP_DD_NGAYDD").datepicker({
        changeMonth: true,
        changeYear: true,

        dateFormat: 'dd/mm/yy'
    });


    $("#KH_LOP_DD_NGAYDD").mask("99/99/9999", { placeholder: "dd/mm/yyyy" });
    //$("#KH_LOP_LH_DENNGAY").mask("99/99/9999", { placeholder: "dd/mm/yyyy" });

    // cho phep nhap so thap phan (su dung jquery.number)
    //$("#GV_THAMNIENLX").number(true, 2, '.', '');

</script>

@Styles.Render("~/Content/themes/base/css")

@section scripts
{
    @Scripts.Render("~/Scripts/select2.js")
}

<link href="~/Scripts/select2.css" rel="stylesheet" />

@*<script>
    $(document).ready(function () {
        $("#ddlCars").select2({
            placeholder: "Chọn học viên..",
            maximumSelectionSize: 100
        });

    });
</script>*@


<script type="text/javascript">
    $(document).ready(function () {

        // load district by province when change in dropdownlist
        $("#ddlDVGTVT_MA").change(function () {
            var _MaGTVT = $(this).val();
            if (_MaGTVT != null && _MaGTVT != '') {
                $.ajax({
                    url: 'getKH_MAs',
                    type: 'post',
                    data: {
                        ma_DVGT: $('#ddlDVGTVT_MA').val()
                    }
                }).done(function (response) {
                    // update district by province
                    var a = '<option value></option>' + response;   // defaut value
                    $("#ddlKH_MA").html(a);

                    // reset ward
                    var b = '<option value></option>'
                    $('#ddlLOP_MA').html(b);


                });
            }
            else {
                var a = '<option value></option>'  // defaut value
                $("#ddlKH_MA").html(a);

                // reset ward
                var b = '<option value></option>'
                $('#ddlLOP_MA').html(b);
            }





        });

        // load ward by disctrict when change in dropdownlist
        $("#ddlKH_MA").change(function () {
            var _MaKH = $(this).val();
            if (_MaKH != null && _MaKH != '') {
                $.ajax({
                    url: 'getKH_LOP_MAs',
                    type: 'post',
                    data: {
                        ma_KH: $('#ddlKH_MA').val()
                    }
                }).done(function (response) {
                    var a = '<option value></option>' + response;   // defaut value
                    $("#ddlLOP_MA").html(a);

                });
            }
            else {
                // reset ward
                var b = '<option value></option>'
                $('#ddlLOP_MA').html(b);
            }

        });


        // load ward by ddlHTDT_MA when change in dropdownlist
        $("#ddlLOP_MA").change(function () {
            var _MA_LOP = $('#ddlLOP_MA').val();
            if (_MA_LOP != null && _MA_LOP != '') {


                //Get danh sach hoc vien cua lop

                $.ajax({
                    url: 'getHV_MAs',
                    type: 'post',
                    data: {
                        Ma_DVGT: $('#ddlDVGTVT_MA').val(),
                        ma_KH: $('#ddlKH_MA').val(),
                        ma_LOP: $('#ddlLOP_MA').val()
                    }
                }).done(function (response) {
                    var a = '<option value></option>' + response;   // defaut value
                    $("#ddlCars").html(a);

                });

                $("#ddlCars").select2({
                    placeholder: "Chọn học viên..",
                    maximumSelectionSize: 5
                });

            }
            else {
                alert("Hãy nhập Mã lớp!");
            }


        });

    })
</script>
